home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 12143 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.2 KB

  1. Path: news.compuserve.com!newsmaster
  2. From: 76623,2065@compuserve.com  (Bobby Martin)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: C++ newbie asks for help
  5. Date: 18 Mar 1996 16:28:29 GMT
  6. Organization: CompuServe Incorporated
  7. Message-ID: <4ik2vd$euq@dub-news-svc-4.compuserve.com>
  8. References: <31488AC8.1557@cco.caltech.edu>
  9. Reply-To: 76623,2065@compuserve.com (Bobby Martin)
  10. NNTP-Posting-Host: ad51-239.compuserve.com
  11. X-Newsreader: IBM NewsReader/2 v1.03
  12.  
  13. In <31488AC8.1557@cco.caltech.edu>, Xuhua Li <xuhua@cco.caltech.edu> writes:
  14. >The following C++ programs from Stephen Prata's book <<C++ Primer Plus>>
  15. >does not work properly compiled by Microsoft C++ 4.0 under Window 95. 
  16. >Can anybody help me out there?
  17.  
  18. <snip>
  19.  
  20. Your problem in the first program (and possibly the second, I'm not sure...)
  21. is that cout is buffered, and the actual write from the buffer to the screen
  22. either happens whenever the buffer is full or the compiler feels like putting it
  23. in (I know there are some controlling criteria here but I'm unsure what they
  24. are), or when you explicitely say so using 'flush' or 'endl'.
  25.  
  26. In short, to solve your problem end your cout's with 'endl' instead of \n
  27. like this:
  28.  
  29.     cout << "starting\a" << endl;
  30.  
  31. instead of
  32.  
  33.     cout << "starting\a\n";
  34.  
  35. Hope that helps
  36.  
  37. Bobby Martin
  38.